package me.thinkjet.staticmng.handler;

import com.jfinal.handler.Handler;
import me.thinkjet.staticmng.service.ImgService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ImgHandler extends Handler {

	@Override
	public void handle(String target, HttpServletRequest request,
	                   HttpServletResponse response, boolean[] isHandled) {
		if (target.startsWith("/upload/imgs")) {
			if (target.indexOf(ImgService.THUMB_FLAG) > 0) {
				ImgService.createThumbs(target);
			}
		}
		this.nextHandler.handle(target, request, response, isHandled);
	}

}
